package com.efesco.service.compensation;

import com.bstek.dorado.common.*;
import com.bstek.dorado.data.*;
import com.bstek.dorado.data.db.DBStatement;
import com.bstek.dorado.view.*;
import com.bstek.dorado.view.data.*;
import com.bstek.dorado.view.control.*;
import com.efesco.common.CommUtil;
import com.efesco.common.DBTools;

/**
 * V_insure_type_formViewModel
 */
public class V_insure_type_formViewModel extends DefaultViewModel {
  public void init(int state)
      throws Exception {
    // Add your code here
    super.init(state);
  }

  protected void initDatasets()
      throws Exception {
    super.initDatasets();
    // Add your code here
  }

  protected void initControls()
      throws Exception {
    super.initControls();
    // Add your code here
  }

  protected void doLoadData()
      throws Exception {
    // Add your code here
    super.doLoadData();
  }

  protected void doUpdateData(ParameterSet parameters)
      throws Exception {
    Dataset dataset_insure_type=this.getDataset("dataset_insure_type");
     //CommUtil.doUpdateData(dataset_insure_type, "s_insure_type", "INSURE_TYPE_ID");
	CommUtil.dataUpdate(dataset_insure_type);
	CommUtil.UpdateData(dataset_insure_type,"s_insure_type","INSURE_TYPE_ID");

  }

public void deleteSelection(ParameterSet parameters)
      throws Exception {
    Dataset dataset = getDataset("dataset_insure_type");
//CommUtil.dataDelete(dataset);
 //   super.doUpdateData(parameters);
	
	DBStatement dbs = new DBStatement();
	dataset.moveFirst();
	while(!dataset.isLast()){
		if(dataset.getBoolean("select")){
			dbs.setSql("update s_insure_type set is_valid=0 where insure_type_id="+dataset.getValue("insure_type_id"));
			dbs.execute();
		}			
		dataset.moveNext();
		
	}
	dbs.close();
  }


}
